import { type IApi } from 'umi';

const renderVal = (path: string) => {
  const getYear = new Date().getFullYear();
  const defaultMsg = path.includes('/en')
    ? 'Xlend—Unlock Your Ideal Loan with Xlend! '
    : 'Xlend 閃借 - 全網比較，搵到最啱你嘅貸款方案！亞太地區知名貸款比價撮合平台';
  switch (path) {
    case '/login':
      return `<title>立即登入或註冊｜Xlend 閃借</title>`;
    case '/en/login':
      return `<title>Login or Signup丨Xlend</title>`;
    case '/':
      return `<title>Xlend 閃借 - 全網比較，搵到最啱你嘅貸款方案！亞太地區知名貸款比價撮合平台</title>
<meta name="keywords" content='香港貸款比較平台|香港貸款|香港私人貸款|香港P LOAN|結餘轉戶貸款|免TU網上貸款|樓按貸款|香港財務公司推薦|香港信用卡申請' />`;
    case '/en/':
      return `<title>Xlend—Unlock Your Ideal Loan with Xlend! </title>
<meta name="keywords" content='Hong Kong Loan Comparison Platform丨Hong Kong Loan丨Hong Kong Personal Loan丨Hong Kong P Loan丨Debt Consolidation Loans丨TU-Free Online Loan丨Mortgage丨Top Money Lenders in Hong Kong丨Credit Card Application in Hong Kong' />`;
    // 产品
    case '/product':
      return `<title>低息私人貸款推薦${getYear}｜快速簡易申請，免煩惱資金周轉</title>
<meta name="description" content='香港貸款比較平台|香港貸款|香港私人貸款|香港P LOAN|結餘轉戶貸款|免TU網上貸款|樓按貸款|香港財務公司推薦|香港信用卡申請' />`;
    case '/en/product':
      return `<title>${getYear} Low APR Personal Loan Recommendations | Fast and easy application, worry-free cash flow management</title>
<meta name="description" content='Xlend leverages fintech to creat an intelligent loan matching platform. We are dedicated to providing accurate, fast, and free loan product selection services for individuals seeking loans, through AI and cloud computing technology. We help customers find the loan products with the lowest cost and highest amount to meet their funding needs and improve their financial situation.
XLEND, for easier loans and a fairer financial system!' />`;
    // 活动
    case '/exclusive':
      return `<title>優惠活動｜Xlend 閃借，亞太地區領先貸款比價撮合平台，快速幫您搵到錢！</title>`;
    case '/en/exclusive':
      return `<title>Promotion Activity丨XLEND is a leading loan comparison and matching platform in the Asia-Pacific region, offering quik loan matching services.</title>`;
    // 返利
    case '/cashback':
      return `<title>現金獎勵｜Xlend 閃借，亞太地區領先貸款比價撮合平台，快速幫您搵到錢！</title>`;
    case '/en/cashback':
      return `<title>Cash Rewards丨XLEND is a leading loan comparison and matching platform in the Asia-Pacific region, offering quik loan matching services.</title>`;
    // 问题
    case '/problem':
      return `<title>常見問題｜Xlend 閃借，亞太地區領先貸款比價撮合平台，快速幫您搵到錢！</title>`;
    case '/en/problem':
      return `<title>FAQs丨XLEND is a leading loan comparison and matching platform in the Asia-Pacific region, offering quik loan matching services</title>`;
    // 关于
    case '/about':
      return `<title>關於我們 ｜Xlend 閃借，亞太地區領先貸款比價撮合平台，快速幫您搵到錢！</title>`;
    case '/en/about':
      return `<title>About Us丨XLEND is a leading loan comparison and matching platform in the Asia-Pacific region, offering quik loan matching services</title>`;
    // 金融快訊
    case '/news':
      return `<title>金融快訊｜Xlend 閃借，亞太地區領先貸款比價撮合平台，快速幫您搵到錢！</title>`;
    case '/en/news':
      return `<title>Event News丨XLEND is a leading loan comparison and matching platform in the Asia-Pacific region, offering quik loan matching services</title>`;
    // 个人资料

    case '/center':
      return `<title>填寫個人資料｜Xlend 閃借</title>`;
    case '/en/center':
      return `<title>Personal Information丨XLEND is a leading loan comparison and matching platform in the Asia-Pacific region, offering quik loan matching services</title>`;
    default:
      return `<title>${defaultMsg}</title>`;
  }
};
export default (api: IApi) => {
  // const lang = localStorage.getItem('umi_locale');
  api.modifyHTML(($, options) => {
    const append = (val: string) => {
      $('head').append([val]);
    };
    const { path } = options;

    const html = ` 
 <link rel="manifest" href="/manifest.json">
<link rel="alternate" hreflang="en" href="https://xlend.hk/en" />
<link rel="alternate" hreflang="zh" href="https://xlend.hk" />
<link rel="alternate" hreflang="x-default" href="https://xlend.hk" />`;
    append(renderVal(path));
    append(html);
    return $;
  });
};
